package org.seven.jrdp.web.t;

import java.util.List;

import org.seven.jrdp.biz.t.model.TJh;
import org.seven.jrdp.biz.t.service.TJhService;
import org.seven.jrdp.commons.model.Option;
import org.seven.jrdp.commons.model.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

@RestController
@RequestMapping("/mgt/t/jh")
public class TJhController {
	@Autowired
	private TJhService tJhService;

	@GetMapping("/{view}")
	public ModelAndView view(@PathVariable String view) {
		return new ModelAndView("mgt/t/jh/jh_" + view);
	}

	@PostMapping("/find")
	public List<TJh> find() {
		List<TJh> list = tJhService.find();
		return list;
	}

	@RequestMapping("/get")
	public TJh get(String id) {
		TJh tJh = tJhService.get(id);
		return tJh;
	}

	@PostMapping("/insert")
	public Result insert(TJh tJh) {
		tJhService.insert(tJh);
		return Result.SUCCESS;
	}

	@PostMapping("/update")
	public Result update(TJh tJh) {
		tJhService.update(tJh);
		return Result.SUCCESS;
	}

	@PostMapping("/delete")
	public Result delete(String id) {
		tJhService.delete(id);
		return Result.SUCCESS;
	}

	@RequestMapping("/option")
	public List<Option> option() {
		return tJhService.getOption();
	}
}